﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using COM.Web;
using WebApp.Data;

namespace WebApp.Web
{
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public partial class WcfDataService : DataService<TempFileDbContext>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = System.Data.Services.Common.DataServiceProtocolVersion.V2;
            config.UseVerboseErrors = true;
        }

        protected override void HandleException(HandleExceptionArgs args)
        {
            //FileLogService.Instance.Log(args.Exception.Message);
            base.HandleException(args);
        }


        private WebApp.Service.IRuntimeService runtimeService = COM.Web.Unity.Instance.GetService<WebApp.Service.IRuntimeService>();
        private WebApp.Data.TempFileUser user = null;
        protected override void OnStartProcessingRequest(ProcessRequestArgs args)
        {
            this.user = this.runtimeService.Permission.CurrentUser as WebApp.Data.TempFileUser;
            base.OnStartProcessingRequest(args);
        }

      
    }
}
